/**
*
* DAVENGINE 
*
*/
#include "stdafx.h"
#include "Init.h"


//-------------------------------------------------------------------------------------
Init::Init(void)
{
}
//-------------------------------------------------------------------------------------
Init::~Init(void)
{
}

//-------------------------------------------------------------------------------------
void Init::createScene(void)
{
     mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f));
 
    // Create an Entity
    Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "robot.mesh");

 
    // Create a SceneNode and attach the Entity to it
    Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode");
    headNode->attachObject(ogreHead);

	headNode->yaw(Ogre::Radian(Ogre::Math::PI / 2));

		mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);
	mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_MODULATIVE);
    mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f));

	Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
	Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
    plane, 1500, 1500, 20, 20, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);

	Ogre::Entity* entGround = mSceneMgr->createEntity("GroundEntity", "ground");
	Ogre::SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode();

	entGround->setMaterialName("Examples/Rockwall");
	entGround->setCastShadows(false); 
	
	node->attachObject(entGround);
	
	mCameraMan->setTarget(headNode); 
	mCameraMan->setCameraMode(CameraManager::FIRST_PERSON);
 //OgreConsole::getSingleton().addCommand("quit",&CMD_Quit);
 //OgreConsole::getSingleton().addCommand("screenshot",&CMD_Screenshot);
 
    // Create a Light and set its position
    Ogre::Light* light = mSceneMgr->createLight("MainLight");
    light->setPosition(20.0f, 80.0f, 50.0f);
}



#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
    INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
    int main(int argc, char *argv[])
#endif
    {
        // Create application object
        Init app;

        try {
            app.go();
        } catch( Ogre::Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
            MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
            std::cerr << "An exception has occured: " <<
                e.getFullDescription().c_str() << std::endl;
#endif
        }

        return 0;
    }

#ifdef __cplusplus
}
#endif
